﻿<BarcodeReader OnInit="@OnInit" OnResult="@OnResult" OnStart="@OnStart" OnClose="@OnClose" OnError="@OnError" />

@code {
    private Task OnInit(IEnumerable<Camera> devices)
    {
        var cams = string.Join("", devices.Select(i => i.Label));
        Trace?.Log($"初始化摄像头完成 {cams}");
        return Task.CompletedTask;
    }

    private Task OnResult(string barcode)
    {
        Trace?.Log($"扫描到条码 {barcode}");
        return Task.CompletedTask;
    }

    private Task OnError(string error)
    {
        Trace?.Log($"发生错误 {error}");
        return Task.CompletedTask;
    }

    private Task OnStart()
    {
        Trace?.Log($"打开摄像头");
        return Task.CompletedTask;
    }

    private Task OnClose()
    {
        Trace?.Log($"关闭摄像头");
        return Task.CompletedTask;
    }
}
